﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
namespace SQT.tracnghiem.Ajax.ASP.Class
{
    public partial class merge_class : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int from = int.Parse(Request.QueryString["from"]);
            int to = int.Parse(Request.QueryString["to"]);

            var get_user = new TblUserController().FetchAll().Where(x => x.ClassX == from);
            foreach (TblUser user in get_user)
            {
                new TblUserController().Update(user.UserId, user.NumberStudy, user.UserName, user.UserPass, user.FullName, user.BirthDay, user.Phone, user.Avatar, user.Email, user.AddressMail, user.Address, user.Facebook, user.Sex, user.UserLevel, to, user.Active, user.SignInDate,user.Wallpaper, user.Note);
            }

            var get_check = new TblCheckUserController().FetchAll().Where(x => x.ClassX == from);
            foreach (TblCheckUser check in get_check)
            {
                new TblCheckUserController().Update(check.Id, check.UserId, to, check.DateX, check.Shifts, check.Early, check.Late, check.AbsentYes, check.AbsentNo);
            }

            new TblClassController().Destroy(from);
        }
    }
}